# -*- coding: utf-8 -*-
'''
Created on 2011-8-21

@author: zxz
'''

from sqlalchemy import Column, Integer, BigInteger, FLOAT, String, CHAR, DateTime
from datasource import Base
from common.DateUtil import getStdTimeStr

class LocationPlace(Base):
    ''' 位置信息 '''
    __tablename__ = 'location_place'
    id = Column(BigInteger, primary_key=True)
    place = Column(String(128), nullable=True)
    address = Column(String(256), nullable=True)
    latitude = Column(FLOAT, nullable=False)
    longitude = Column(FLOAT, nullable=False)
    use_cnt = Column(Integer, primary_key=True)
    tags = Column(String(32), nullable=True)
    gmt_create = Column(DateTime, nullable=False)

    def __init__(self, place, address, latitude, longitude, use_cnt, tags, gmt_create):
        self.place = place
        self.address = address
        self.latitude = latitude
        self.longitude = longitude
        self.use_cnt = use_cnt
        self.tags = tags
        self.gmt_create = gmt_create

    def __repr__(self):
        return '<Location %r>' % self.id

    def entity(self):
        return {'id':self.id, 'place' : self.place, 'address' : self.address, 'latitude' : self.latitude, 'longitude' : self.longitude, 'use_cnt' : self.use_cnt, 'tags' : self.tags, 'gmt_create' : getStdTimeStr(self.gmt_create)}

